var Dialog = function(){
    return Dialog.fn.init();
}


Dialog.fn = Dialog.prototype = {
	html:null,
	tmplNameBase:'modal',
	tmplPathBase:'dialog',
	//size:{
//		max:'modal-lg',
//		min:'modal-sm'
//	},


	// Init
	init:function(){},

   /**
	* Show Dialog
	* @param:
	*/
	showDialog: function (attributes)
	{
		var _this = this;

		// Size

		if(attributes.size ) {
			switch(attributes.size)
			{
				case 'max':
					attributes.size = 'modal-lg';
					break;
				case 'min':
					attributes.size = 'modal-sm';
					break;
			}

		}


		if(attributes && !$.isEmptyObject(attributes)) {
			$.when(
				template.load(_this.tmplNameBase, _this.tmplPathBase)
			).then(function(tmpl){

				_this.html = $(template.render(tmpl, attributes));

				_this.html.modal({
					  keyboard: false
				});
			});
		}
	},

	/**
	 * after render
	 * @param:
	 */
	after: function (tmpName, tmpPath)
	{
		var def = $.Deferred();
		var url = '/homes/loadJsTemplate/' + tmpName + '/' + tmpPath;

		$.when( loader.getAjax(url, false, 'html') ).then(function(jshtml){
			def.resolve(jshtml);
		});

		return def;
	}


};

var dialog = new Dialog();